package com.xuanxing123.model;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name="selection",catalog="xuanxing")
@Searchable
@XmlRootElement
public class Selection extends BaseObject implements Serializable {
    private Long id;
    private User user;
    private Industry industry;
    private ProductType productType;
    private String industryOther;
    private Integer companyType;
    private String companyOther;
    private Integer annualSalesVolume;
    private Integer annualIncreaseRate;
    private Integer numbeOfEmployees;
    private String companyRemark;
    private String moduleRemark;
    private Integer totalBudget;
    private Integer numberOfUsers;
    private Integer implCycle;
    private Integer structure;
    private String useRemark;
    private Integer important1;
    private Integer important2;
    private Integer important3;
    private String importantRemark;
    private Boolean supportContactInfo;
    private Set<SelectionProduct> selectionProducts = new HashSet<SelectionProduct>(0);
    private Set<SelectionModule> selectionModules = new HashSet<SelectionModule>(0);
    private SelectionContactInfo selectionContactInfo;

    @Id
    @GeneratedValue(strategy=IDENTITY)
    @SearchableId
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="user_id", nullable=false)
    public User getUser() {
        return this.user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="type_id", nullable=false)
    public ProductType getProductType() {
        return this.productType;
    }

    public void setProductType(ProductType productType) {
        this.productType = productType;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="industry_id", nullable=false)
    public Industry getIndustry() {
        return this.industry;
    }

    public void setIndustry(Industry industry) {
        this.industry = industry;
    }
    
    @Column(name="industry_other", length=100)
    @SearchableProperty
    public String getIndustryOther() {
        return this.industryOther;
    }
    
    public void setIndustryOther(String industryOther) {
        this.industryOther = industryOther;
    }
    
    @Column(name="company_type")
    @SearchableProperty
    public Integer getCompanyType() {
        return this.companyType;
    }
    
    public void setCompanyType(Integer companyType) {
        this.companyType = companyType;
    }
    
    @Column(name="company_other", length=100)
    @SearchableProperty
    public String getCompanyOther() {
        return this.companyOther;
    }
    
    public void setCompanyOther(String companyOther) {
        this.companyOther = companyOther;
    }
    
    @Column(name="annual_sales_volume")
    @SearchableProperty
    public Integer getAnnualSalesVolume() {
        return this.annualSalesVolume;
    }
    
    public void setAnnualSalesVolume(Integer annualSalesVolume) {
        this.annualSalesVolume = annualSalesVolume;
    }
    
    @Column(name="annual_increase_rate")
    @SearchableProperty
    public Integer getAnnualIncreaseRate() {
        return this.annualIncreaseRate;
    }
    
    public void setAnnualIncreaseRate(Integer annualIncreaseRate) {
        this.annualIncreaseRate = annualIncreaseRate;
    }
    
    @Column(name="numbe_of_employees")
    @SearchableProperty
    public Integer getNumbeOfEmployees() {
        return this.numbeOfEmployees;
    }
    
    public void setNumbeOfEmployees(Integer numbeOfEmployees) {
        this.numbeOfEmployees = numbeOfEmployees;
    }
    
    @Column(name="company_remark", length=254)
    @SearchableProperty
    public String getCompanyRemark() {
        return this.companyRemark;
    }
    
    public void setCompanyRemark(String companyRemark) {
        this.companyRemark = companyRemark;
    }
    
    @Column(name="module_remark", length=254)
    @SearchableProperty
    public String getModuleRemark() {
        return this.moduleRemark;
    }
    
    public void setModuleRemark(String moduleRemark) {
        this.moduleRemark = moduleRemark;
    }
    
    @Column(name="total_budget", nullable=false)
    @SearchableProperty
    public Integer getTotalBudget() {
        return this.totalBudget;
    }
    
    public void setTotalBudget(Integer totalBudget) {
        this.totalBudget = totalBudget;
    }
    
    @Column(name="number_of_users", nullable=false)
    @SearchableProperty
    public Integer getNumberOfUsers() {
        return this.numberOfUsers;
    }
    
    public void setNumberOfUsers(Integer numberOfUsers) {
        this.numberOfUsers = numberOfUsers;
    }
    
    @Column(name="impl_cycle", nullable=false)
    @SearchableProperty
    public Integer getImplCycle() {
        return this.implCycle;
    }
    
    public void setImplCycle(Integer implCycle) {
        this.implCycle = implCycle;
    }
    
    @Column(name="structure", nullable=false)
    @SearchableProperty
    public Integer getStructure() {
        return this.structure;
    }
    
    public void setStructure(Integer structure) {
        this.structure = structure;
    }
    
    @Column(name="use_remark", length=254)
    @SearchableProperty
    public String getUseRemark() {
        return this.useRemark;
    }
    
    public void setUseRemark(String useRemark) {
        this.useRemark = useRemark;
    }
    
    @Column(name="important1")
    @SearchableProperty
    public Integer getImportant1() {
        return this.important1;
    }
    
    public void setImportant1(Integer important1) {
        this.important1 = important1;
    }
    
    @Column(name="important2")
    @SearchableProperty
    public Integer getImportant2() {
        return this.important2;
    }
    
    public void setImportant2(Integer important2) {
        this.important2 = important2;
    }
    
    @Column(name="important3")
    @SearchableProperty
    public Integer getImportant3() {
        return this.important3;
    }
    
    public void setImportant3(Integer important3) {
        this.important3 = important3;
    }
    
    @Column(name="important_remark", length=254)
    @SearchableProperty
    public String getImportantRemark() {
        return this.importantRemark;
    }
    
    public void setImportantRemark(String importantRemark) {
        this.importantRemark = importantRemark;
    }
    
    @Column(name="support_contact_info")
    @SearchableProperty
    public Boolean getSupportContactInfo() {
        return this.supportContactInfo;
    }
    
    public void setSupportContactInfo(Boolean supportContactInfo) {
        this.supportContactInfo = supportContactInfo;
    }

    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="selection")
    public Set<SelectionProduct> getSelectionProducts() {
        return this.selectionProducts;
    }
    
    public void setSelectionProducts(Set<SelectionProduct> selectionProducts) {
        this.selectionProducts = selectionProducts;
    }

    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="selection")
    public Set<SelectionModule> getSelectionModules() {
        return this.selectionModules;
    }
    
    public void setSelectionModules(Set<SelectionModule> selectionModules) {
        this.selectionModules = selectionModules;
    }

    @OneToOne(cascade = CascadeType.ALL)
    @PrimaryKeyJoinColumn
    public SelectionContactInfo getSelectionContactInfo() {
        return this.selectionContactInfo;
    }
    
    public void setSelectionContactInfo(SelectionContactInfo selectionContactInfo) {
        this.selectionContactInfo = selectionContactInfo;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Selection pojo = (Selection) o;

        if (user != null ? !user.equals(pojo.user) : pojo.user != null) return false;
        if (industryOther != null ? !industryOther.equals(pojo.industryOther) : pojo.industryOther != null) return false;
        if (companyType != null ? !companyType.equals(pojo.companyType) : pojo.companyType != null) return false;
        if (companyOther != null ? !companyOther.equals(pojo.companyOther) : pojo.companyOther != null) return false;
        if (annualSalesVolume != null ? !annualSalesVolume.equals(pojo.annualSalesVolume) : pojo.annualSalesVolume != null) return false;
        if (annualIncreaseRate != null ? !annualIncreaseRate.equals(pojo.annualIncreaseRate) : pojo.annualIncreaseRate != null) return false;
        if (numbeOfEmployees != null ? !numbeOfEmployees.equals(pojo.numbeOfEmployees) : pojo.numbeOfEmployees != null) return false;
        if (companyRemark != null ? !companyRemark.equals(pojo.companyRemark) : pojo.companyRemark != null) return false;
        if (moduleRemark != null ? !moduleRemark.equals(pojo.moduleRemark) : pojo.moduleRemark != null) return false;
        if (totalBudget != null ? !totalBudget.equals(pojo.totalBudget) : pojo.totalBudget != null) return false;
        if (numberOfUsers != null ? !numberOfUsers.equals(pojo.numberOfUsers) : pojo.numberOfUsers != null) return false;
        if (implCycle != null ? !implCycle.equals(pojo.implCycle) : pojo.implCycle != null) return false;
        if (structure != null ? !structure.equals(pojo.structure) : pojo.structure != null) return false;
        if (useRemark != null ? !useRemark.equals(pojo.useRemark) : pojo.useRemark != null) return false;
        if (important1 != null ? !important1.equals(pojo.important1) : pojo.important1 != null) return false;
        if (important2 != null ? !important2.equals(pojo.important2) : pojo.important2 != null) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = (user != null ? user.hashCode() : 0);
        result = 31 * result + (industryOther != null ? industryOther.hashCode() : 0);
        result = 31 * result + (companyType != null ? companyType.hashCode() : 0);
        result = 31 * result + (companyOther != null ? companyOther.hashCode() : 0);
        result = 31 * result + (annualSalesVolume != null ? annualSalesVolume.hashCode() : 0);
        result = 31 * result + (annualIncreaseRate != null ? annualIncreaseRate.hashCode() : 0);
        result = 31 * result + (numbeOfEmployees != null ? numbeOfEmployees.hashCode() : 0);
        result = 31 * result + (companyRemark != null ? companyRemark.hashCode() : 0);
        result = 31 * result + (moduleRemark != null ? moduleRemark.hashCode() : 0);
        result = 31 * result + (totalBudget != null ? totalBudget.hashCode() : 0);
        result = 31 * result + (numberOfUsers != null ? numberOfUsers.hashCode() : 0);
        result = 31 * result + (implCycle != null ? implCycle.hashCode() : 0);
        result = 31 * result + (structure != null ? structure.hashCode() : 0);
        result = 31 * result + (useRemark != null ? useRemark.hashCode() : 0);
        result = 31 * result + (important1 != null ? important1.hashCode() : 0);
        result = 31 * result + (important2 != null ? important2.hashCode() : 0);
        result = 31 * result + (important3 != null ? important3.hashCode() : 0);
        result = 31 * result + (importantRemark != null ? importantRemark.hashCode() : 0);
        result = 31 * result + (supportContactInfo != null ? supportContactInfo.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("user").append("='").append(getUser()).append("', ");
        sb.append("industryOther").append("='").append(getIndustryOther()).append("', ");
        sb.append("companyType").append("='").append(getCompanyType()).append("', ");
        sb.append("companyOther").append("='").append(getCompanyOther()).append("', ");
        sb.append("annualSalesVolume").append("='").append(getAnnualSalesVolume()).append("', ");
        sb.append("annualIncreaseRate").append("='").append(getAnnualIncreaseRate()).append("', ");
        sb.append("numbeOfEmployees").append("='").append(getNumbeOfEmployees()).append("', ");
        sb.append("companyRemark").append("='").append(getCompanyRemark()).append("', ");
        sb.append("moduleRemark").append("='").append(getModuleRemark()).append("', ");
        sb.append("totalBudget").append("='").append(getTotalBudget()).append("', ");
        sb.append("numberOfUsers").append("='").append(getNumberOfUsers()).append("', ");
        sb.append("implCycle").append("='").append(getImplCycle()).append("', ");
        sb.append("structure").append("='").append(getStructure()).append("', ");
        sb.append("useRemark").append("='").append(getUseRemark()).append("', ");
        sb.append("important1").append("='").append(getImportant1()).append("', ");
        sb.append("important2").append("='").append(getImportant2()).append("', ");
        sb.append("important3").append("='").append(getImportant3()).append("', ");
        sb.append("importantRemark").append("='").append(getImportantRemark()).append("', ");
        sb.append("supportContactInfo").append("='").append(getSupportContactInfo()).append("', ");
        
        
        
        sb.append("]");
      
        return sb.toString();
    }

}
